/**************************************************************************(C)*
 *
 *  This file is part of the GreenHills project
 *  Copyright (C) 2009  Tieto Corporation
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  Not for commmercial use. Only with Tieto permission.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************(C)*/

#include "gpsinfowidget.h"
#include "ui_gpsinfowidget.h"

#include "gps/gps.h"

using namespace greenhills::client;
using namespace greenhills::gps;

CGPSInfoWidget::CGPSInfoWidget(CGPS *pGps, QWidget *pParent)
    :CAutoLayoutWidget(pParent),
    mUi(new Ui::CGPSInfoWidget),
    mGps(pGps)
{
    mUi->setupUi(this);

    QObject::connect(mGps, SIGNAL(statusChanged()),
        this, SLOT(onStatusChanged()));

    CAutoLayoutWidget::addWidget(mUi->widget);
    CAutoLayoutWidget::addWidget(mUi->widget_2);
}

CGPSInfoWidget::~CGPSInfoWidget()
{
    delete mUi;
}

void CGPSInfoWidget::onStatusChanged()
{
    mUi->leTime->setText(mGps->time().toString());
    mUi->leLatitude->setText(mGps->position().latitude().toString());
    mUi->leLongitude->setText(mGps->position().longitude().toString());
    mUi->leFix->setText(mGps->fix().toString());
    mUi->leSatelites->setText(QString::number(mGps->satelites()));
    mUi->leHDOP->setText(QString::number(mGps->hdop()));
    mUi->leAltitude->setText(QString::number(mGps->altitude()));
    mUi->leHeading->setText(QString::number(mGps->movementDirection()));
    mUi->leSpeedKmH->setText(QString::number(mGps->movementSpeed()));
}
